/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Reservations.java
 *
 * Created on 30 janv. 2011, 15:29:42
 */
package org.cinema.view.user;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
import org.cinema.dao.carteabonne.CarteAbonnesDao;
import org.cinema.dao.carteabonne.CarteAbonnesInfo;
import org.cinema.dao.reservation.ReservationsDao;
import org.cinema.dao.reservation.ReservationsInfo;
import org.cinema.dao.salle.SallesDao;
import org.cinema.dao.seance.SeancesDao;
import org.cinema.dao.seance.SeancesInfo;
import org.cinema.dao.typecarte.TypeCartesDao;
import org.cinema.dao.typecarte.TypeCartesInfo;
import org.cinema.utils.PdfGenerator;

/**
 *
 * @author Administrateur
 */
public class Reservations extends javax.swing.JPanel
{
       // SeanceElement seanceE;
	SeancesInfo s;
	ReservationsDao rDao;
	ReservationsInfo rInfos;
	int NcarteA;
        int NcarteT;
        int nbP;
	boolean d3;
	double TroisD = 1;

    private final JFrame reserV;
    private SeanceElement elmt;

	/** Creates new form Reservations */
	public Reservations(SeancesInfo s, boolean d3,JFrame reser)

	{       this.reserV=reser;
		this.d3 = d3;
		this.s = s;
		if (d3)
		{
			TroisD = 1.5;
		}
                nbP=getNbPlaceDispo(s);
                System.out.println(nbP);
            
		initComponents();
                jLabel3.setText(""+nbP);
                jLabel5.setText(""+nbP);
                jLabel7.setText(""+nbP);
		this.jLabelNenfantCr.setVisible(false);
		this.jTextEnfantCr.setVisible(false);

	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jButtonValidezNB = new javax.swing.JButton();
        jLabelPrixNB = new javax.swing.JLabel();
        jTextPrixNB = new javax.swing.JTextField();
        jLabelPlaceNB = new javax.swing.JLabel();
        jTextPlaceNB = new javax.swing.JTextField();
        jButtonAchatNB = new javax.swing.JButton();
        jLabelPrix = new javax.swing.JLabel();
        jLabel3D = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jComboBoxCreduction = new javax.swing.JComboBox();
        jLabelCreduction = new javax.swing.JLabel();
        jComboBoxPlaceCreduction = new javax.swing.JComboBox();
        jLabelPlacecReduction = new javax.swing.JLabel();
        jLabelNcReduction = new javax.swing.JLabel();
        jTextNcReduction = new javax.swing.JTextField();
        jButtonValidezCr = new javax.swing.JButton();
        jLabelPrixCr = new javax.swing.JLabel();
        jTextPrixCr = new javax.swing.JTextField();
        jButtonAchatCr = new javax.swing.JButton();
        jTextEnfantCr = new javax.swing.JTextField();
        jLabelNenfantCr = new javax.swing.JLabel();
        jLabelEuroCr = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabelPlacesA = new javax.swing.JLabel();
        jLabelCarteA = new javax.swing.JLabel();
        jTextNcarteA = new javax.swing.JTextField();
        jButtonValidezCa = new javax.swing.JButton();
        jLabelPrixCa = new javax.swing.JLabel();
        jTextPrixCa = new javax.swing.JTextField();
        jButtonAchatA = new javax.swing.JButton();
        jComboBoxPlaceA = new javax.swing.JComboBox();
        jLabelEuroA = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();

        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.cinema.view.user.CinemaApp.class).getContext().getResourceMap(Reservations.class);
        jTabbedPane1.setBackground(resourceMap.getColor("jTabbedPane1.background")); // NOI18N
        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jButtonValidezNB.setFont(resourceMap.getFont("jButtonValidezNB.font")); // NOI18N
        jButtonValidezNB.setText(resourceMap.getString("jButtonValidezNB.text")); // NOI18N
        jButtonValidezNB.setName("jButtonValidezNB"); // NOI18N
        jButtonValidezNB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonValidezNBActionPerformed(evt);
            }
        });

        jLabelPrixNB.setFont(resourceMap.getFont("jLabelPrixNB.font")); // NOI18N
        jLabelPrixNB.setLabelFor(jComboBoxCreduction);
        jLabelPrixNB.setText(resourceMap.getString("jLabelPrixNB.text")); // NOI18N
        jLabelPrixNB.setName("jLabelPrixNB"); // NOI18N

        jTextPrixNB.setName("jTextPrixNB"); // NOI18N
        jTextPrixNB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextPrixNBActionPerformed(evt);
            }
        });

        jLabelPlaceNB.setFont(resourceMap.getFont("placesNB.font")); // NOI18N
        jLabelPlaceNB.setText(resourceMap.getString("placesNB.text")); // NOI18N
        jLabelPlaceNB.setName("placesNB"); // NOI18N

        jTextPlaceNB.setName("jTextPlaceNB"); // NOI18N

        jButtonAchatNB.setFont(resourceMap.getFont("jButtonAchatNB.font")); // NOI18N
        jButtonAchatNB.setText(resourceMap.getString("jButtonAchatNB.text")); // NOI18N
        jButtonAchatNB.setEnabled(false);
        jButtonAchatNB.setName("jButtonAchatNB"); // NOI18N
        jButtonAchatNB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAchatNBActionPerformed(evt);
            }
        });

        jLabelPrix.setText(resourceMap.getString("jLabelPrix.text")); // NOI18N
        jLabelPrix.setName("jLabelPrix"); // NOI18N

        jLabel3D.setText(resourceMap.getString("jLabel3D.text")); // NOI18N
        jLabel3D.setName("jLabel3D"); // NOI18N

        jLabel2.setFont(resourceMap.getFont("jLabel2.font")); // NOI18N
        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setBackground(resourceMap.getColor("jLabel3.background")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelPlaceNB, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(45, 45, 45)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButtonAchatNB, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(59, 59, 59)
                                        .addComponent(jTextPrixNB, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(47, 47, 47)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jLabel3D, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabelPrix))))
                                .addGap(58, 58, 58))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(28, 28, 28)
                                .addComponent(jTextPlaceNB, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(jButtonValidezNB, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(12, 12, 12)
                        .addComponent(jLabelPrixNB, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(jLabel2)
                        .addGap(3, 3, 3)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(83, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelPlaceNB)
                        .addComponent(jTextPlaceNB, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabelPrix)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3D)))
                .addGap(36, 36, 36)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonValidezNB, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelPrixNB)
                    .addComponent(jTextPrixNB, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)
                .addComponent(jButtonAchatNB, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(40, 40, 40))
        );

        jTabbedPane1.addTab("Non Abonné", jPanel1);

        jPanel3.setBackground(resourceMap.getColor("jPanel3.background")); // NOI18N
        jPanel3.setName("jPanel3"); // NOI18N

        jComboBoxCreduction.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "carte jeune", "carte étudiant", "carte famille", "carte militaire", "carte chomeur" }));
        jComboBoxCreduction.setName("jComboBoxCreduction"); // NOI18N
        jComboBoxCreduction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxCreductionActionPerformed(evt);
            }
        });

        jLabelCreduction.setFont(resourceMap.getFont("jLabelCreduction.font")); // NOI18N
        jLabelCreduction.setText(resourceMap.getString("jLabelCreduction.text")); // NOI18N
        jLabelCreduction.setName("jLabelCreduction"); // NOI18N

        jComboBoxPlaceCreduction.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1" }));
        jComboBoxPlaceCreduction.setName("jComboBoxPlaceCreduction"); // NOI18N
        jComboBoxPlaceCreduction.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxPlaceCreductionActionPerformed(evt);
            }
        });

        jLabelPlacecReduction.setFont(resourceMap.getFont("jLabelPlacecReduction.font")); // NOI18N
        jLabelPlacecReduction.setText(resourceMap.getString("jLabelPlacecReduction.text")); // NOI18N
        jLabelPlacecReduction.setName("jLabelPlacecReduction"); // NOI18N

        jLabelNcReduction.setFont(resourceMap.getFont("jLabelNcReduction.font")); // NOI18N
        jLabelNcReduction.setText(resourceMap.getString("jLabelNcReduction.text")); // NOI18N
        jLabelNcReduction.setName("jLabelNcReduction"); // NOI18N

        jTextNcReduction.setName("jTextNcReduction"); // NOI18N

        jButtonValidezCr.setFont(resourceMap.getFont("jButtonValidezCr.font")); // NOI18N
        jButtonValidezCr.setText(resourceMap.getString("jButtonValidezCr.text")); // NOI18N
        jButtonValidezCr.setName("jButtonValidezCr"); // NOI18N
        jButtonValidezCr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonValidezCrActionPerformed(evt);
            }
        });

        jLabelPrixCr.setFont(resourceMap.getFont("jLabelPrixCr.font")); // NOI18N
        jLabelPrixCr.setText(resourceMap.getString("jLabelPrixCr.text")); // NOI18N
        jLabelPrixCr.setName("jLabelPrixCr"); // NOI18N

        jTextPrixCr.setName("jTextPrixCr"); // NOI18N

        jButtonAchatCr.setFont(resourceMap.getFont("jButtonAchatCr.font")); // NOI18N
        jButtonAchatCr.setText(resourceMap.getString("jButtonAchatCr.text")); // NOI18N
        jButtonAchatCr.setEnabled(false);
        jButtonAchatCr.setName("jButtonAchatCr"); // NOI18N
        jButtonAchatCr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAchatCrActionPerformed(evt);
            }
        });

        jTextEnfantCr.setName("jTextEnfantCr"); // NOI18N

        jLabelNenfantCr.setFont(resourceMap.getFont("jLabelNenfantCr.font")); // NOI18N
        jLabelNenfantCr.setText(resourceMap.getString("jLabelNenfantCr.text")); // NOI18N
        jLabelNenfantCr.setName("jLabelNenfantCr"); // NOI18N

        jLabelEuroCr.setFont(resourceMap.getFont("jLabelEuroCr.font")); // NOI18N
        jLabelEuroCr.setText(resourceMap.getString("jLabelEuroCr.text")); // NOI18N
        jLabelEuroCr.setName("jLabelEuroCr"); // NOI18N

        jLabel4.setFont(resourceMap.getFont("jLabel4.font")); // NOI18N
        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabelCreduction, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jComboBoxCreduction, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(51, 51, 51)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabelNcReduction, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(81, 81, 81)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextNcReduction, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addComponent(jButtonValidezCr, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(64, 64, 64)
                                        .addComponent(jLabelPrixCr, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jTextPrixCr, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabelEuroCr))))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabelPlacecReduction, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(49, 49, 49)
                                .addComponent(jComboBoxPlaceCreduction, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabelNenfantCr, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextEnfantCr, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(276, 276, 276)
                        .addComponent(jButtonAchatCr, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(86, 86, 86)
                        .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(17, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCreduction)
                    .addComponent(jComboBoxCreduction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelPlacecReduction)
                    .addComponent(jLabelNenfantCr)
                    .addComponent(jComboBoxPlaceCreduction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextEnfantCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(26, 26, 26)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextNcReduction, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelNcReduction))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextPrixCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelPrixCr)
                    .addComponent(jLabelEuroCr)
                    .addComponent(jButtonValidezCr))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addComponent(jButtonAchatCr)
                .addGap(31, 31, 31))
        );

        jTabbedPane1.addTab(resourceMap.getString("jPanel3.TabConstraints.tabTitle"), jPanel3); // NOI18N

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jLabelPlacesA.setFont(resourceMap.getFont("jLabelPlacesA.font")); // NOI18N
        jLabelPlacesA.setText(resourceMap.getString("jLabelPlacesA.text")); // NOI18N
        jLabelPlacesA.setName("jLabelPlacesA"); // NOI18N

        jLabelCarteA.setFont(resourceMap.getFont("jLabelCarteA.font")); // NOI18N
        jLabelCarteA.setText(resourceMap.getString("jLabelCarteA.text")); // NOI18N
        jLabelCarteA.setName("jLabelCarteA"); // NOI18N

        jTextNcarteA.setName("jTextNcarteA"); // NOI18N

        jButtonValidezCa.setFont(resourceMap.getFont("jButtonValidezCa.font")); // NOI18N
        jButtonValidezCa.setText(resourceMap.getString("jButtonValidezCa.text")); // NOI18N
        jButtonValidezCa.setName("jButtonValidezCa"); // NOI18N
        jButtonValidezCa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonValidezCaActionPerformed(evt);
            }
        });

        jLabelPrixCa.setFont(resourceMap.getFont("jLabelPrixCa.font")); // NOI18N
        jLabelPrixCa.setText(resourceMap.getString("jLabelPrixCa.text")); // NOI18N
        jLabelPrixCa.setName("jLabelPrixCa"); // NOI18N

        jTextPrixCa.setName("jTextPrixCa"); // NOI18N

        jButtonAchatA.setFont(resourceMap.getFont("jButtonAchatA.font")); // NOI18N
        jButtonAchatA.setText(resourceMap.getString("jButtonAchatA.text")); // NOI18N
        jButtonAchatA.setEnabled(false);
        jButtonAchatA.setName("jButtonAchatA"); // NOI18N
        jButtonAchatA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAchatAActionPerformed(evt);
            }
        });

        jComboBoxPlaceA.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3" }));
        jComboBoxPlaceA.setName("jComboBoxPlaceA"); // NOI18N

        jLabelEuroA.setFont(resourceMap.getFont("jLabelEuroA.font")); // NOI18N
        jLabelEuroA.setText(resourceMap.getString("jLabelEuroA.text")); // NOI18N
        jLabelEuroA.setName("jLabelEuroA"); // NOI18N

        jLabel6.setFont(resourceMap.getFont("jLabel6.font")); // NOI18N
        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(174, 174, 174)
                        .addComponent(jButtonAchatA, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(jButtonValidezCa, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(32, 32, 32)
                        .addComponent(jLabelPrixCa, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jTextPrixCa, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabelEuroA))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(57, 57, 57)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabelCarteA, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jTextNcarteA))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabelPlacesA, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(26, 26, 26)
                                .addComponent(jComboBoxPlaceA, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(88, 88, 88)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(144, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBoxPlaceA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelPlacesA))
                .addGap(51, 51, 51)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelCarteA)
                    .addComponent(jTextNcarteA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextPrixCa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelEuroA)
                    .addComponent(jLabelPrixCa)
                    .addComponent(jButtonValidezCa))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
                .addComponent(jButtonAchatA)
                .addGap(36, 36, 36))
        );

        jTabbedPane1.addTab("Abonné", jPanel2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jTextPrixNBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextPrixNBActionPerformed
		// TODO add your handling code here:
    }//GEN-LAST:event_jTextPrixNBActionPerformed

    private void jButtonValidezCaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonValidezCaActionPerformed
		int idSeance = s.getId();
                int nb=jComboBoxPlaceA.getSelectedIndex()+1;
		if (jTextNcarteA.getText().equals(""))
		{
			JOptionPane.showMessageDialog(this, "N carte vide","erreur",JOptionPane.ERROR_MESSAGE);
		}
		else
		{

			NcarteA = Integer.parseInt(jTextNcarteA.getText());
			if (verifyCardA(NcarteA))
			{
				if (verifyReservationAbonné(NcarteA, idSeance))
                                   if (nb>nbP) JOptionPane.showMessageDialog(this, "Nombre places insuffisant","erreur",JOptionPane.ERROR_MESSAGE);
                                   else {
                                       jButtonAchatA.setEnabled(true);
					int prix = jComboBoxPlaceA.getSelectedIndex() + 1;
					jTextPrixCa.setText("" + prix * 6 * TroisD);
				}
				else
				{
					JOptionPane.showMessageDialog(this, "reservation deja effectuer");
				}
			}
			else
			{
				JOptionPane.showMessageDialog(this, "Numero carte invalide","erreur",JOptionPane.ERROR_MESSAGE);
			}
		}


    }//GEN-LAST:event_jButtonValidezCaActionPerformed

    private void jButtonValidezNBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonValidezNBActionPerformed
		int nb=Integer.parseInt(jTextPlaceNB.getText());
                if(nb>nbP) JOptionPane.showMessageDialog(this, "NB places insuffisant","erreur",JOptionPane.ERROR_MESSAGE);
                else if (jTextPlaceNB.getText().equals(""))
		{
			JOptionPane.showMessageDialog(this, "NB places vide","erreur",JOptionPane.ERROR_MESSAGE);
		}
		else
		{
                        jButtonAchatNB.setEnabled(true);
			int prix = Integer.parseInt(jTextPlaceNB.getText());
			jTextPrixNB.setText("" + prix * 8 * TroisD);
		}
    }//GEN-LAST:event_jButtonValidezNBActionPerformed

    private void jButtonAchatNBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAchatNBActionPerformed
        SeanceElement seanceE= new  SeanceElement();
        List<Integer> l= new ArrayList<Integer>();
        int nb=Integer.parseInt(jTextPlaceNB.getText());
		ReservationsDao res = new ReservationsDao();
        for (int i=1; i<=nb;i++){
            ReservationsInfo reser=new ReservationsInfo( 0,0,s.getId());
        if(res.saveReservation(reser));

                l.add(reser.getId());
        }
        
		System.out.println("opeation effectuer") ;
		         String titre ="Non Abonné";
            String text = "\nNuméro de la réservation :"
                        + l.toString()
                    + "\n\nDate d'achat du carte : " + new Date(System.currentTimeMillis());
         
            new PdfGenerator(text,titre);
            elmt.setSeance(new SeancesDao().getSeance(s.getId()));
            reserV.dispose();
        
	//else System.out.println("erreur interne");
    }//GEN-LAST:event_jButtonAchatNBActionPerformed

    private void jButtonAchatAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAchatAActionPerformed
		// TODO add your handling code here:
        SeanceElement seanceE= new  SeanceElement();
                List<Integer> l= new ArrayList<Integer>();
		ReservationsDao res = new ReservationsDao();
                CarteAbonnesDao cA = new  CarteAbonnesDao();
                String nom= cA.getCarteAbonne(NcarteA).getNom();
                String prenom= cA.getCarteAbonne(NcarteA).getPrenom();
                ReservationsInfo reser=new ReservationsInfo(NcarteA, 0,s.getId());
        int nb=(jComboBoxPlaceA.getSelectedIndex()+1);
	for(int i=1; i<=nb;i++){
        if	(res.saveReservation(reser))
             l.add(reser.getId());else System.out.println ("erreur interne");
            }
        String titre ="Reservation Abonné";
           String text = "\nNom : " + nom
                + "\nPrenom : " + prenom
                    + "\nNuméro de la carte : "
                   + reser.getId()
                   +"\n N:séance:"+reser.getSeanceId()
                   + "\nNuméro de la réservation :"
                        + l.toString()
                   + "\n\nDate d'achat de la carte : "
                  + new Date(System.currentTimeMillis());
         new PdfGenerator(text,titre);
         elmt.setSeance(new SeancesDao().getSeance(s.getId()));
          reserV.dispose();

            System.out.println("operation ok");
    
    //}
    }//GEN-LAST:event_jButtonAchatAActionPerformed

    private void jButtonAchatCrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAchatCrActionPerformed
        //        List<Integer> l= new ArrayList<Integer>();
        //        int nb=Integer.parseInt(jTextPlaceNB.getText());
        SeanceElement seanceE= new  SeanceElement();
        ReservationsDao res = new ReservationsDao();
        TypeCartesDao  typeC= new TypeCartesDao();
        String nom=typeC.getTypeCarte(NcarteT).getNom();
        ReservationsInfo reser=new ReservationsInfo( 0,NcarteT,s.getId());
        if(res.saveReservation(reser)){
            String titre ="Reservation avec Carte  réduction";
            String text = "\nNuméro de la réservation :" + reser.getId()
                    +"\nNuméro de la séance:"+ reser.getSeanceId()
                    +"\nType carte:" + nom
                    + "\n\nDate d'achat du carte : " + new Date(System.currentTimeMillis());
            new PdfGenerator(text,titre);

            System.out.println("operation ok");
               elmt.setSeance(new SeancesDao().getSeance(s.getId()));
            reserV.dispose();

            // else  System.out.println("erreur interne");
        }
}//GEN-LAST:event_jButtonAchatCrActionPerformed

    private void jButtonValidezCrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonValidezCrActionPerformed
        // int id=s.getId();
        int idSeance = s.getId();
        int nb;
        if (jTextNcReduction.getText().equals("")) {
            JOptionPane.showMessageDialog(this, "N carte vide","erreur",JOptionPane.ERROR_MESSAGE);
        } else {

            NcarteT = Integer.parseInt(jTextNcReduction.getText());
            if (verifyCardT(NcarteT)) {
                if (verifyReservationTypeCarte(NcarteT, idSeance)) {
                    if (!jTextEnfantCr.isVisible()) {
                        jButtonAchatCr.setEnabled(true);
                        jTextPrixCr.setText("" + 5*TroisD);
                    } else if (jTextEnfantCr.isVisible() && !(jTextEnfantCr.getText().equals(""))) {       //nombre totale de place
                        int p1 = jComboBoxPlaceCreduction.getSelectedIndex() + 5;
                        if (p1>nbP)JOptionPane.showMessageDialog(this, "N place insuffisant","erreur",JOptionPane.ERROR_MESSAGE);
                        // nombre d'enfants
                        else{
                            int p2 = Integer.parseInt(jTextEnfantCr.getText());
                            int p3 = (p1-p2)*7;
                            p2=p2*4;
                            // prix total
                            int prix = p2 + p3;

                            jButtonAchatCr.setEnabled(true);
                            jTextPrixCr.setText("" + prix * TroisD);
                        }} else {
                        JOptionPane.showMessageDialog(this, "N Place vide","erreur",JOptionPane.ERROR_MESSAGE);
                        }


                } else {
                    JOptionPane.showMessageDialog(this, "Resevation déja effectué");
                }
            } else {
                JOptionPane.showMessageDialog(this, "N carte invalide","erreur",JOptionPane.ERROR_MESSAGE);
                jTextNcReduction.setText("");
                jTextPrixCr.setText("");
            }

        }
}//GEN-LAST:event_jButtonValidezCrActionPerformed

    private void jComboBoxPlaceCreductionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxPlaceCreductionActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jComboBoxPlaceCreductionActionPerformed

    private void jComboBoxCreductionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxCreductionActionPerformed

        this.jLabelNenfantCr.setVisible(false);
        this.jTextEnfantCr.setVisible(false);
        jComboBoxPlaceCreduction.removeAllItems();
        jComboBoxPlaceCreduction.addItem(1);
        if (jComboBoxCreduction.getSelectedItem().equals("carte famille")) {
            jComboBoxPlaceCreduction.removeAllItems();
            this.jLabelNenfantCr.setVisible(true);
            this.jTextEnfantCr.setVisible(true);
            for (int i = 5; i < 20; i++) {
                jComboBoxPlaceCreduction.addItem(i);
            }
        }
}//GEN-LAST:event_jComboBoxCreductionActionPerformed

	public boolean verifyCardA(int idCarte)
	{
		CarteAbonnesDao Allcards = new CarteAbonnesDao();
		boolean ok = false;
		List<CarteAbonnesInfo> l;
		l = Allcards.allCarteAbonne();

		for (CarteAbonnesInfo i : l)
		{
			if (i.getId() == idCarte)
			{
				ok = true;
			}
		}
		//System.out.println(i.getId());
		return ok;
	}

	public boolean verifyCardT(int idTypeCarte)
	{
		TypeCartesDao AllTypes = new TypeCartesDao();
		boolean ok = false;
		List<TypeCartesInfo> l;
		l = AllTypes.allTypeCarte();
		for (TypeCartesInfo i : l)
		{
			if (i.getId() == idTypeCarte /*&& i.getNom().equals(jComboBoxCreduction.getSelectedItem())*/)
			{
				ok = true;
			}
		}

		return ok;
	}
	//verification pour les reservations si un client à effectuer une reservation ou non pour une seance

	public boolean verifyReservationAbonné(int Ncarte, int idseance)
	{

		ReservationsDao Allres = new ReservationsDao();

		boolean ok = true;
		List<ReservationsInfo> l;
		l = Allres.allReservation();
		if (l == null)
		{
			ok = true;
		}
		else
		{
			for (ReservationsInfo i : l)
			{
				if (i.getSeanceId() == idseance && i.getCarteAbonneId() == Ncarte)
				{
					ok = false;
				}
			}
		}
		return ok;
	}

	public boolean verifyReservationTypeCarte(int NtypeCarte, int idseance)
	{

		ReservationsDao Allres = new ReservationsDao();

		boolean ok = true;
		List<ReservationsInfo> l;
		l = Allres.allReservation();
		if (l == null)
		{
			ok = true;
		}
		else
		{
			for (ReservationsInfo i : l)
			{
				if (i.getSeanceId() == idseance && i.getTypeCarteId() == NtypeCarte)
				{
					ok = false;
				}
			}
		}
		return ok;
	}
         public int getNbPlaceDispo(SeancesInfo s){
    int nbPlaces=0;
    ReservationsDao reDao=new ReservationsDao();
    SallesDao sDao=new SallesDao();
/*    List<SallesInfo> l;
    l=sDao.allSalle();
*/
	nbPlaces = sDao.getSalle(s.getSalleid()).getNbPlace();
    /*for (SallesInfo i:l) { if (s.getSalleid()==i.getId()){

        nbPlaces = i.getNbPlace();}
    }*/

//    int IDseance=SeanceElement.getId();
    int palaces=0;
    List<ReservationsInfo> lr;
    lr=reDao.allReservation();
    for (ReservationsInfo i :lr )
       // System.out.println(i.getId());
        if (i.getSeanceId()==
        s.getId())
            palaces++;
       // System.out.println(palaces);
     nbPlaces=nbPlaces -palaces;
     return nbPlaces;
 }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonAchatA;
    private javax.swing.JButton jButtonAchatCr;
    private javax.swing.JButton jButtonAchatNB;
    private javax.swing.JButton jButtonValidezCa;
    private javax.swing.JButton jButtonValidezCr;
    private javax.swing.JButton jButtonValidezNB;
    private javax.swing.JComboBox jComboBoxCreduction;
    private javax.swing.JComboBox jComboBoxPlaceA;
    private javax.swing.JComboBox jComboBoxPlaceCreduction;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel3D;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabelCarteA;
    private javax.swing.JLabel jLabelCreduction;
    private javax.swing.JLabel jLabelEuroA;
    private javax.swing.JLabel jLabelEuroCr;
    private javax.swing.JLabel jLabelNcReduction;
    private javax.swing.JLabel jLabelNenfantCr;
    private javax.swing.JLabel jLabelPlaceNB;
    private javax.swing.JLabel jLabelPlacecReduction;
    private javax.swing.JLabel jLabelPlacesA;
    private javax.swing.JLabel jLabelPrix;
    private javax.swing.JLabel jLabelPrixCa;
    private javax.swing.JLabel jLabelPrixCr;
    private javax.swing.JLabel jLabelPrixNB;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField jTextEnfantCr;
    private javax.swing.JTextField jTextNcReduction;
    private javax.swing.JTextField jTextNcarteA;
    private javax.swing.JTextField jTextPlaceNB;
    private javax.swing.JTextField jTextPrixCa;
    private javax.swing.JTextField jTextPrixCr;
    private javax.swing.JTextField jTextPrixNB;
    // End of variables declaration//GEN-END:variables

    void onNBPlaceChange(SeanceElement aThis) {
        elmt = aThis;

    }
}
